Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
ICSM Computer
16-May-2025To check if a file is an image, PDF, or audio file by inspecting its content, you should analyze the file signature (also known as the "magic number")—a specific byte pattern at the beginning of the file that indicates its type.
1. Read the File Header (Magic Number)
Here's a C# example:
2. Common Signatures
FF D8 FF89 50 4E 47 0D 0A 1A 0A25 50 44 46%PDF49 44 33ID3at start (ID3v2)52 49 46 46RIFF(check next bytes)47 49 46 38GIF8To distinguish between
WAVandAVI, you'd need to check the next few bytes afterRIFF.3. Notes